#ifndef _csType_h_
#define _csType_h_

/********************************************************************
	created:	2009/11/05
	created:	5:11:2009   10:00
	filename: 	e:\CoreLib\CoreLib\src\csType.h
	file path:	e:\CoreLib\CoreLib\src
	file base:	csType
	file ext:	h
	author:		dongchengok
	
	purpose:	fuck the type define
*********************************************************************/

#ifdef _WIN32

typedef char				c8;
typedef wchar_t				c16;
typedef unsigned int		c32;

typedef signed char			s8;
typedef signed short		s16;
typedef signed int			s32;
typedef signed __int64		s64;

typedef unsigned char		u8;
typedef unsigned short		u16;
typedef unsigned int		u32;
typedef unsigned __int64	u64;

typedef float				f32;
typedef double				f64;

typedef const char*			pcstr;
typedef const wchar_t*		pwstr;

#ifdef _MSC_VER
#pragma warning( disable : 4251 )       // class XX needs DLL interface to be used...
#pragma warning( disable : 4355 )       // initialization list uses 'this' 
#pragma warning( disable : 4267 )		// conversion from 'size_t' to 'int', possible loss of data
#pragma warning( disable : 4275 )       // base class has not dll interface...
#pragma warning( disable : 4786 )       // symbol truncated to 255 characters
#pragma warning( disable : 4530 )       // C++ exception handler used, but unwind semantics not enabled
#pragma warning( disable : 4995 )       // _OLD_IOSTREAMS_ARE_DEPRECATED
#pragma warning( disable : 4996 )       // _CRT_INSECURE_DEPRECATE, VS8: old string routines are deprecated
#pragma warning( disable : 4512 )       // 'class' : assignment operator could not be generated
#pragma warning( disable : 4610 )       // object 'class' can never be instantiated - user-defined constructor required
#pragma warning( disable : 4510 )       // 'class' : default constructor could not be generated
#endif

#else
typedef char				c8;
typedef wchar_t				c16;
typedef unsigned int		c32;

typedef signed char			s8;
typedef signed short		s16;
typedef signed int			s32;
typedef signed long long	s64;

typedef unsigned char		u8;
typedef unsigned short		u16;
typedef unsigned int		u32;
typedef unsigned long long  u64;

typedef float				f32;
typedef double				f64;

typedef const char*			pcstr;
typedef const wchar_t*		pwstr;

#endif


#define csINVALID_INDEX		-1
#define csNULL				0
#define csMAKE_ID(c0, c1, c2, c3) \
((u32)(u8)(c0) | ((u32)(u8)(c1) << 8) | \
((u32)(u8)(c2) << 16) | ((u32)(u8)(c3) << 24 ))

//#ifdef _WIN32
//#include <ctype.h>
//#include <new.h>
//#include <stdio.h>
//#include <io.h>
//#include <locale.h>
//#else
//#include <ctype.h>
//#include <new.h>
//#include <stdio.h>
//#include <stdlib.h>
//#include <locale.h>
//#endif

#if defined(_DEBUG) && defined(_MSC_VER) && (_MSC_VER > 1299) 
#define CRTDBG_MAP_ALLOC
#define _CRTDBG_MAP_ALLOC
#define csNEW					new( _NORMAL_BLOCK, __FILE__, __LINE__)
#include <stdlib.h>
#include <crtdbg.h>
#else
#include <stdlib.h>
#endif

#ifdef csNEW
#define csMemoryTrack()			_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF)
#else
#define csNEW   new
#define csMemoryTrack()
#endif

#define csSAFE_DELETE(p)		if(p){delete p;p=csNULL;}
#define csSAFE_DELETE_ARRAY(p)	if(p){delete[] p;p=csNULL;}
#define csDELETE				delete

#if defined(_WIN32)&&defined(_MSC_VER)
#define csINLINE				__forceinline
#else
#define csINLINE				inline
#endif

#ifdef _DEBUG
#define csASSERT(exp)			if(!(exp)){ __asm int 3}
#else
#define csASSERT
#endif

#define csFILE_SYSTEM_MAX_PATH		1024
#define csALIGNMENT_DEFAULT			8
#define csFASTLIST_DEFAULT_POOL		20
#define csMININUM_STRING_CAPACITY	32

//help function
template<typename T> csINLINE void
csSwap(T& lhs, T& rhs){ T temp = lhs; lhs = rhs; rhs = temp;}


//#ifdef _WIN32
//#include <windows.h>
//#else
//#include <malloc/malloc.h>
//#include <mm_malloc.h>
//#define _aligned_malloc _mm_malloc
//#define _aligned_free   _mm_free
//#endif
//
//#ifndef _WIN32
//#define _vsnprintf  snprintf
//#endif

//unicode define
#ifdef _UNICODE
#define csT(text)	L##text
typedef pwstr		ptstr;
typedef c16			tc;
#else
#define csT(text)	text
typedef pcstr		ptstr;
typedef c8			tc;
#endif

//#include <string.h>
//#include <stdio.h>
//#include <wchar.h>

#endif // _csType_h_